{extend name="public/base"}
{block name='main'}
<style type="text/css">
    .red {color: #FF5722!important;}
    .green {color: #5FB878!important;}
</style>
<fieldset class="layui-elem-field layui-field-title" style="margin-top:0px;">
    <legend>{//$menuid|getmenuname}</legend>
</fieldset>
<form class="layui-form layui-form-pane" action="">
    <div class="my-btn-box">
      <span class="fl">
        <blockquote class="layui-elem-quote">提示：如菜单禁用 ，则后台不显示。</blockquote>
     </span>
        <span class="fr">
        <a class="layui-btn layui-btn-normal" id="btn-add">添加菜单</a>
     </span>
    </div>
</form>
<form class="layui-form layui-form-pane" action="">
    <table class="layui-table">
        <colgroup>
            <col width="50">
            <col width="">
            <col width="100">
            <col width="100">
            <col width="100">
            <col width="200">
        </colgroup>
        <thead>
        <tr>
            <th>ID</th>
            <th>菜单名称</th>
            <th>Url</th>
            <th>排序</th>
            <th>是否启用</th>
            <th>菜单位置</th>
            <th>管理操作</th>
        </tr>
        </thead>
        <tbody id="userList">
        {volist name="list" id="val"}
        <tr>
            <td>{$val.id}</td>
            <td>{$val.html}{$val.name}</td>
            <td>{$val.module_name}-{$val.action_name}-{$val.data}</td>
            <td>{$val.ordid}</td>
            <td><input type="checkbox" name="status" value="{$val.status}" data-uri="{:url('menu/ajax_edit',array('field'=>'status','id'=>$val['id']))}" lay-skin="switch" lay-filter="status" lay-text="启用|禁止" {if($val.status == 1)}checked{/if} >
               </td>
            <td>{$val.style}</td>
            <td>
                {if($val.count<1)}
                <a href="javascript:;" data-uri="{:url('menu/add', array('pid' => $val['id']))}" data-title="添加子菜单" id="add">添加子菜单</a> |
                {/if}
                <a href="javascript:;" data-uri="{:url('menu/edit', array('id' => $val['id']))}" data-title="编辑 - 实用文档" id="edit">编辑</a> |
                <a href="javascript:;" data-acttype="ajax" class="J_confirmurl" id="delete" data-uri="{:url('menu/delete', array('id' => $val['id']))}" data-msg="确定要删除“实用文档”吗？">删除</a></td>
        </tr>
        {/volist}
        {//$list}
        </tbody>

    </table>
</form>
<script type="text/javascript" src="__PUBLIC__/admin/layui/layui.js"></script>
<script>
    //Demo
    layui.use(['layer','jquery','form','element','table'], function () {
        // 操作对象
        var layer = layui.layer,$ = layui.jquery,form = layui.form, element = layui.element,table = layui.table;

        //添加二级
        $(function(){
            $("tbody#userList tr td #add").click(function() {
                var s_title   = $(this).attr('data-title'), s_url = $(this).attr('data-uri') ;
                layer.open({
                    type: 2,
                    title: s_title,
                    area: ['600px', '420px'],
                    fixed: true, //不固定
                    maxmin: true,
                    content: s_url
                });
            });
        });

        //参数：layui、名称、模块名、主键（删除用）
        //新增弹窗
        Oper.config.add.width = '600px';
        Oper.config.add.height = '420px';

        //编辑弹窗
        Oper.config.edit.width = '600px';
        Oper.config.edit.height = '420px';
        Oper.initList(layui, '菜单', 'menu', 'id');

    });
</script>
{/block}